{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>发布任务</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">任务标题：</label>
                            <div class="layui-input-block">
                                <input type="text" name="task_title" lay-verify="required" class="layui-input" placeholder="任务标题">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">接收区域：</label>
                            <div class="layui-input-block">
                                <select name="task_district_ids" xm-select="select1" lay-verify="required" xm-select-search="" xm-select-search-type="dl">
                                    {foreach name="district" item="v"}
                                    <option value="{$v.dis_id}">{$v.dis_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group" id="task_type">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select name="task_type" lay-filter="role1">
                                    <option value="1" selected>文字图片</option>
                                    <option value="2" >文字视频</option>
                                    <option value="3" >文字链接</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">文字素材：</label>
                            <div class="layui-input-block">
                                <textarea name="task_content" placeholder="内容" class="layui-textarea"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10" id='task_images'>
                            <label class="layui-form-label">图集素材：</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="task_images" id="photo" lay-verify="image">
                                <div id="uploader" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10 hidden" id='task_video'>
                            <label class="layui-form-label">视频素材：</label>
                            <div class="layui-input-block" >
                                <input type="hidden" name="task_video" id="qiniuVideo">
                                <button class="layui-btn" style="position: absolute;">选择文件</button>
                                <input class="file-input" type="file" id="select2"  multiple="multiple" accept="video/mp4,video/avi,vide/mkv"/>
                                <table class="layui-table">
                                    <colgroup>
                                        <col width="80">
                                        <col width="100">
                                        <col width="200">
                                        <col width="100">
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>文件名称</th>
                                        <th>文件大小</th>
                                        <th>进度</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody id="fsUploadProgress">
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 hidden" id='task_link'>
                            <label class="layui-form-label">链接：</label>
                            <div class="layui-input-block">
                                <input type="text" name="task_link" class="layui-input" placeholder="链接">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">发布
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<!--—————————————————————七牛云分片上传—————————————————————————-->
<link rel="stylesheet" href="__JS__/qiniu2.0/index.css">
<script type="text/javascript" src='__JS__/qiniu2.0/qiniu.min.js'></script>
<script type="text/javascript" src='__JS__/qiniu2.0/widget.js'></script>
<script type="text/javascript" src='__JS__/qiniu2.0/common.js'></script><!--上传操作-->
<script type="text/javascript" src='__JS__/qiniu2.0/ui.js'></script><!--展示上传表格-->
<script type="text/javascript" src='__JS__/qiniu2.0/uploadWithSDK.js'></script><!--h5上传-->
<script type="text/javascript" src='__JS__/qiniu2.0/main.js'></script><!--调用后台生成token-->
<!--—————————————————————七牛云分片上传—————————————————————————-->
<script>
    var n = wk.uploads({num:9,type:'png,jpg,jpeg',url:"{:url('admin/upload/upload')}"});
    function imgDel(e,obj){
        wk.uploads_del(e,obj,n); // 删除
    }
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
//            data.field.banner_content = editor.txt.html();
//            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('taskAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Task/index')}");
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role1)', function(data){
            if(data.value == 1){
                $('#task_images').removeClass('hidden');
                $('#task_video').addClass('hidden');
                $('#task_link').addClass('hidden');
            }else if(data.value == 2){
                $('#task_images').addClass('hidden');
                $('#task_video').removeClass('hidden');
                $('#task_link').addClass('hidden');
            }else{
                $('#task_images').addClass('hidden');
                $('#task_video').addClass('hidden');
                $('#task_link').removeClass('hidden');
            }
        });
    });

</script>
</body>
</html>
